<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript" src="<?=base_url()?>resource/js/layer/extend/layer.ext.js"></script>
<script>
    function SplitPackage(){
        $('#packageList').attr('display','block');
        layer.open({
            type: 1,
            skin: 'layer-oms-skin',
            title:'包裹信息',
            area: ['600px', '420px'], //宽高
            content: $('#packageList')
        });
    }
    function AddPackage(){
        var RECEIPT=$('#RECEIPT').val();
        if(RECEIPT==''){
            alert('收货地址不能为空');
            return false;
        }
    }
    function printHtml(html) {
        var bodyHtml = document.body.innerHTML;
        document.body.innerHTML = html;
        window.print();
        document.body.innerHTML = bodyHtml;
    }
    function onPrint(pid) {
        var shit='';
        $.post("<?=blang_url('ajax/ajax/CreateBarCode')?>",{'pid':pid},function(data){
            $('#shit').html(data);
            printHtml($('#shit').html());
        });
    }
</script>
<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
        <h1><?=lang('public_ckxq')?></h1>
        <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-list"></i><?=lang('order_ddxq')?></h3>
            </div>
            <div class="panel-body">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab-general" data-toggle="tab"><?=lang('order_ddxq')?></a></li>
                    <?php if($productList):?>
                    <li><a href="#tab-data" data-toggle="tab"><?=lang('order_ddxdcp')?></a></li>
                    <?php endif; ?>
                    <?php if($trackList):?>
                    <li><a href="#tab-links" data-toggle="tab"><?=lang('order_wxgj')?></a></li>
                    <?php endif; ?>
                    <?php if($qcReportList):?>
                    <li><a href="#tab-attribute" data-toggle="tab"><?=lang('order_zjbglb')?></a></li>
                    <?php endif; ?>
                    <?php if($priceOneList):?>
                    <li><a href="#tab-option" data-toggle="tab"><?=lang('order_bjdlb')?></a></li>
                    <?php endif; ?>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="tab-general">
                        <table class="style20170608" cellspacing="0">
                          <tbody>
                            <tr>
                                <td class="tableSubtitle odd"><?=lang('order_wxdh')?></td>
                                <td class="tableContent">
                                    <?=$orderFirst['maintain_id']?>
                                    <div class="pull-right">
                                        <a href="<?=blang_url('orders/Printorder/index/'.$orderFirst['maintain_id'])?>" class="btn btn-primary btn-xs"><?=lang('order_dyddxq')?></a>
                                        <input onclick="SplitPackage()" class="btn btn-oms btn-xs" type="button" value="<?=lang('pk_scbg')?>">
                                    </div>
                                </td>                                                            
                                <td class="tableSubtitle odd"><?=lang('order_dhly')?></td>
                                <td class="tableContent"><?=$orderFirst['siteName']?></td>
                            </tr>
                            <tr>
                                <td class="tableSubtitle even">ID</td>
                                <td class="tableContent">
                                    <?=$orderFirst['source_id']?>
                                    <div class="pull-right">
                                        <a target="_blank" class="btn btn-oms btn-xs" href="<?=blang_url('common/sitesSync/syncOrder/1/?id='.$orderFirst['source_id'].'&sitePrefix='.substr($orderFirst['maintain_id'],0,2))?> ">reLoad</a>
                                    </div>
                                </td>                                                            
                                <td class="tableSubtitle even"><?=lang('order_lydh')?></td>
                                <td class="tableContent"><?=$orderFirst['source_int_id']?></td>
                            </tr>
                            <tr>
                                <td class="tableSubtitle odd"><?=lang('order_wxlx')?></td>
                                <td class="tableContent"><?=$orderFirst['repairName']?></td>                                                            
                                <td class="tableSubtitle odd"><?=lang('public_zt')?></td>
                                <td class="tableContent"><?=$orderFirst['statusName']?></td>
                            </tr>
                            <tr>
                                <td class="tableSubtitle even"><?=lang('order_khyx')?></td>
                                <td class="tableContent"><?=$orderFirst['consumer_email']?></td>                                                            
                                <td class="tableSubtitle even"><?=lang('order_khdh')?></td>
                                <td class="tableContent"><?=$orderFirst['consumer_phone']?></td>
                            </tr>
                            <tr>
                                <td class="tableSubtitle odd"><?=lang('order_khxm')?></td>
                                <td class="tableContent" colspan="3"><?=$orderFirst['consumer_name']?></td>                                                            
                            </tr>
                             <tr>
                                <td class="tableSubtitle even"><?=lang('order_khdz')?></td>
                                <td class="tableContent" colspan="3"><?=$orderFirst['consumer_address']?></td>                                                            
                            </tr>
                            <tr>
                                <td class="tableSubtitle odd"><?=lang('order_khdz')?></td>
                                <td class="tableContent" colspan="3">
                                  <?=$orderFirst['delivery_country']?>-
                                  <?=$orderFirst['delivery_city']?>-
                                  <?=$orderFirst['delivery_state']?>-
                                  <?=$orderFirst['delivery_street_address']?>-
                                  <?=$orderFirst['delivery_zipcode']?>
                                </td>                                                            
                            </tr>
                            <tr>
                                <td class="tableSubtitle even"><?=lang('order_khjd')?></td>
                                <td class="tableContent"><?=$orderFirst['delivery_street_address']?></td>                                                            
                                <td class="tableSubtitle even"><?=lang('order_khcs')?></td>
                                <td class="tableContent"><?=$orderFirst['delivery_city']?></td>
                            </tr>
                            <tr>
                                <td class="tableSubtitle odd"><?=lang('order_khz')?></td>
                                <td class="tableContent"><?=$orderFirst['delivery_state']?></td>                                                            
                                <td class="tableSubtitle odd"><?=lang('order_khgj')?></td>
                                <td class="tableContent"><?=$orderFirst['delivery_country']?></td>
                            </tr>
                            <tr>
                                <td class="tableSubtitle even"><?=lang('order_khyb')?></td>
                                <td class="tableContent"><?=$orderFirst['delivery_zipcode']?></td>                                                           
                                <td class="tableSubtitle even"><?=lang('order_zzh')?></td>
                                <td class="tableContent"><?=$orderFirst['track_num']?></td>
                            </tr>
                            <tr>
                                <td class="tableSubtitle odd"><?=lang('order_lhzzh')?></td>
                                <td class="tableContent"><?=$orderFirst['source_track_num']?></td>                                                            
                                <td class="tableSubtitle odd">price_type</td>
                                <td class="tableContent"><?=$orderFirst['price_type']?></td>
                            </tr>
                            <tr>
                                <td class="tableSubtitle even">repairer</td>
                                <td class="tableContent"><?=$orderFirst['repairer']?></td>                                                           
                                <td class="tableSubtitle even">website_origin</td>
                                <td class="tableContent"><?=$orderFirst['website_origin']?></td>
                            </tr>
                          </tbody>
                        </table>
                    </div>
                    <?php if($productList):?>
                    <div class="tab-pane" id="tab-data">
                        <table class="table table-bordered table-hover oms-table">
                            <thead>
                            <tr>
                                <th class="text-left">id</th>
                                <th class="text-left"><?=lang('product_cptype')?></th>
                                <th class="text-left"><?=lang('brand_ppmc')?></th>
                                <th class="text-left"><?=lang('product_cpxh')?></th>
                                <th class="text-right">sku</th>
                                <th class="text-right">imei</th>
                                <th class="text-right"><?=lang('public_zt')?></th>
                                <th class="text-right" style="width:20%;"><?=lang('public_cz')?></th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($productList as $key=>$rs):?>
                                <tr>
                                    <td class="text-left"><?=$rs['product_id']?></td>
                                    <td class="text-left"><?=$rs['sort_name']?></td>
                                    <td class="text-left"><?=$rs['brand_name']?></td>
                                    <td class="text-left"><?=$rs['product_model']?></td>
                                    <td class="text-right"><?=$rs['sku']?></td>
                                    <td class="text-right"><?=$rs['imei']?></td>
                                    <td class="text-right"><?=$rs['is_sipping']==0?'':lang('pk_ysc')."<a class='btn btn-danger btn-sm' style='margin-left:5px;' href='".blang_url('orders/package/GetPackageData/'.$orderFirst['maintain_id'])."'>".lang('pk_bg')."</a>"?></td>
                                    <td class="text-right">
                                        <a class="btn btn-primary btn-sm" href="<?=blang_url('products/product/inDetails/'.$rs['product_id'])?>" ><?=lang('public_ckxq')?></a>
                                        <?php
                                        $roleArr = explode(',',$this->users['role_id']);
                                        if( in_array(5,$roleArr)):?>
                                            <a class="btn btn-primary btn-sm" href="<?=blang_url('products/product/repair_product/'.$rs['product_id'])?>" ><?=lang('product_jxwx')?></a>
                                            <a class="btn btn-primary btn-sm" href="<?=blang_url('products/product/peijian/'.$rs['product_id'].'/'.$rs['maintain_id'])?>" ><?=lang('product_pjgl')?></a>
                                        <?php else:?>
                                            <a class="btn btn-primary btn-sm" href="<?=blang_url('products/product/edit/'.$rs['product_id'])?>" title="<?=lang('public_editText')?>"><i class="fa fa-edit"></i></a>
                                            <a class="btn btn-primary btn-sm" href="<?=blang_url('products/product/qc_product/'.$rs['product_id'])?>" ><?=lang('product_jxzj')?></a>
                                        <?php endif;?>
                                        <a class="btn btn-danger btn-sm" href="<?=blang_url('products/product/del/'.$rs['product_id'].'/'.$page)?>" onclick="return confirm('<?=lang('public_isdel')?>')" title="<?=lang('public_sc')?>"><i class="fa fa-trash-o"></i></a>
                                        <a class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="onPrint(<?=$rs['product_id']?>)">打印条码</a>
                                    </td>
                                </tr>
                            <?php endforeach;?>
                            </tbody>
                        </table>
                        <?php if($show_pages):?>
                        <div class="page">
                            <?=$show_pages?>
                        </div>
                        <?php endif;?>
                    </div>
                    <?php endif; ?>
                    <?php if($trackList):?>
                    <div class="tab-pane" id="tab-links">
                       <table class="table table-bordered table-hover oms-table">
                            <thead>
                            <tr>
                                <th class="text-left"><?=lang('public_zt')?></th>
                                <th class="text-left"><?=lang('order_gxrq')?></th>
                                <th class="text-right"><?=lang('order_clr')?></th>
                                <th class="text-right"><?=lang('order_sfytb')?></th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($trackList as $key=>$rs):?>
                                <tr>
                                    <td class="text-left"><?=$rs['status_name']?></td>
                                    <td class="text-left"><?=$rs['add_time']?></td>
                                    <td class="text-right"><?=$rs['modified_user']?></td>
                                    <td class="text-right"><?=$rs['is_sync_yet']?></td>
                                </tr>
                            <?php endforeach;?>
                            </tbody>
                        </table>
                        <?php if($show_pages):?>
                        <div class="page">
                            <?=$show_pages?>
                        </div>
                        <?php endif;?>
                    </div>
                    <?php endif; ?>
                    <?php if($qcReportList):?>
                    <div class="tab-pane" id="tab-attribute">
                        <table class="table table-bordered table-hover oms-table">
                            <thead>
                            <tr>
                                <th class="text-left"><?=lang('product_cpid')?></th>
                                <th class="text-left"><?=lang('product_sspp')?></th>
                                <th class="text-left"><?=lang('product_cpxh')?></th>
                                <th class="text-left"><?=lang('product_mssfyz')?></th>
                                <th class="text-left"><?=lang('product_wgzk')?></th>
                                <th class="text-right" width="15%"><?=lang('product_sjfj')?></th>
                                <th class="text-right" width="15%"><?=lang('product_gz')?></th>
                                <th class="text-right"><?=lang('public_cjrq')?></th>
                                <th class="text-right"><?=lang('product_tjr')?></th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($qcReportList as $key=>$rs):?>
                                <tr>
                                    <td class="text-left"><?=$rs['pid']?></td>
                                    <td class="text-left"><?=$rs['brand_name']?></td>
                                    <td class="text-left"><?=$rs['product_model']?></td>
                                    <td class="text-left"><?=$rs['is_description']?'Yes':'No'?></td>
                                    <td class="text-left"><?=$rs['damage']?></td>
                                    <td class="text-right"><?=$rs['attachment']?></td>
                                    <td class="text-right"><?=$rs['fault']?></td>
                                    <td class="text-right"><?=$rs['add_time']?></td>
                                    <td class="text-right"><?=$rs['add_user']?></td>
                                </tr>
                            <?php endforeach;?>
                            </tbody>
                        </table>
                        <?php if($show_pages):?>
                        <div class="page">
                            <?=$show_pages?>
                        </div>
                        <?php endif;?>
                    </div>
                    <?php endif; ?>
                    <?php if($priceOneList):?>
                    <div class="tab-pane" id="tab-option">
                        <table class="table table-bordered table-hover oms-table">
                            <thead>
                            <tr>
                                <th class="text-left"><?=lang('product_cpid')?></th>
                                <th class="text-left"><?=lang('price_sgf')?></th>
                                <th class="text-left"><?=lang('price_pjf')?></th>
                                <th class="text-left"><?=lang('price_yf')?></th>
                                <th class="text-left"><?=lang('price_hbzl')?></th>
                                <th class="text-left" width="15%"><?=lang('product_wxx')?></th>
                                <th class="text-right">Total Price</th>
                                <th class="text-right"><?=lang('price_sfjsbj')?></th>
                                <th class="text-right"><?=lang('price_bjsbjfy')?></th>
                                <th class="text-right"><?=lang('public_cjrq')?></th>
                                <th class="text-right"><?=lang('product_tjr')?></th>
                            </tr>
                            </thead>
                            <?php if($show_pages):?>
                                <tfoot>
                                <tr><th colspan="11" height="45"><?=$show_pages?> </th></tr>
                                </tfoot>
                            <?php endif;?>
                            <tbody>
                            <?php foreach ($priceOneList as $key=>$rs):?>
                                <tr>
                                    <td class="text-left"><?=$rs['pid']?></td>
                                    <td class="text-left"><?=$rs['maintain_price']?></td>
                                    <td class="text-left"><?=$rs['accessory_price']?></td>
                                    <td class="text-left"><?=$rs['freight_price']?></td>
                                    <td class="text-left"><?=$rs['price_sort']?></td>
                                    <td class="text-left"><?=$rs['part']?></td>
                                    <td class="text-right" style="color:red;font-size: 14px;" title="手工费+配件费+运费+额外费-优惠费">
                                        <?php
                                            $totalPrice = (float)$rs['maintain_price'].'+'.(float)$rs['accessory_price'].'+'.(float)$rs['freight_price'].'+'.(float)$orderFirst['append_money'].'-'.(float)$orderFirst['coupon_money'].'=';
                                            $totalPrice .= $rs['maintain_price']+$rs['accessory_price']+$rs['freight_price']+$orderFirst['append_money']-$orderFirst['coupon_money'];
                                            echo $totalPrice;
                                        ?>
                                    </td>
                                    <td class="text-right">
                                        <?php if($rs['is_accept_price']==='1'): ?>
                                            YES
                                            <a class="btn btn-primary btn-xs" href="<?=blang_url('products/product/accept_price/'.$rs['pid'])?>" target="_blank" > Re-Quote(重新报价) </a>
                                        <?php elseif($rs['is_accept_price']==='0'): ?>
                                            NO
                                            <a class="btn btn-primary btn-xs" href="<?=blang_url('products/product/accept_price/'.$rs['pid'])?>" target="_blank" > Re-Quote(重新报价) </a>
                                        <?php else: ?>
                                            <a class="btn btn-primary btn-xs" href="<?=blang_url('products/product/accept_price/'.$rs['pid'].'/'.'1')?>" target="_blank" ><?=lang('order_bjtybj')?></a>
                                            <a class="btn btn-primary btn-xs" href="<?=blang_url('products/product/accept_price/'.$rs['pid'].'/'.'0')?>" target="_blank" ><?=lang('order_bjbtybj')?></a><br>
                                            <?=lang('order_bjddcl')?>
                                        <?php endif; ?>

                                    </td>
                                    <td class="text-right" style="color:red;font-size: 14px;" title="手工费+运费+额外费-优惠费">
                                        <?php
                                        $noTotalPrice = (float)$rs['no_accept_price'].'+'.(float)$rs['freight_price'].'+'.(float)$orderFirst['append_money'].'-'.(float)$orderFirst['coupon_money'].'=';
                                        $noTotalPrice .= $rs['no_accept_price']+$rs['freight_price']+$orderFirst['append_money']-$orderFirst['coupon_money'];
                                        echo $noTotalPrice;
                                        ?>
                                    </td>
                                    <td class="text-right"><?=$rs['add_time']?></td>
                                    <td class="text-right">
                                        <?=$rs['add_user']?>
                                        <a class="btn btn-oms btn-xs" href="<?=blang_url('common/test/setbaojia/'.$rs['pid'])?>" target="_blank">Reload</a>
                                    </td>
                                </tr>
                            <?php endforeach;?>
                            </tbody>
                        </table>
                    </div>
                    <?php endif; ?>
                    
                </div>
            </div>
        </div>
    </div>


    <form style="display: none;padding:20px;" id="packageList" action="<?=blang_url('orders/package/AddPackage/'.$orderFirst['maintain_id'])?>" method="post">
        <table id="tPackage" class="table table-bordered table-hover oms-table">
            <thead>
            <tr>
                <th class="text-left">id</th>
                <th class="text-left"><?=lang('product_cptype')?></th>
                <th class="text-left"><?=lang('brand_ppmc')?></th>
                <th class="text-right"><?=lang('product_cpxh')?></th>
                <th class="text-right"><?=lang('pk_xz')?></th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($productList as $key=>$rs):?>
                <?php if($rs['is_sipping']=='0'){ $i=1;?>
                    <tr>
                        <td class="text-left"><?=$rs['product_id']?></td>
                        <td class="text-left"><?=$rs['sort_name']?></td>
                        <td class="text-left"><?=$rs['brand_name']?></td>
                        <td class="text-right"><?=$rs['product_model']?></td>
                        <td class="text-right">
                            <input value="<?=$rs['product_id']?>" type="checkbox" name="product_id[]" checked>
                        </td>
                    </tr>
                <?php }?>
            <?php endforeach;?>
                </tbody>
        </table>
        <table class="style20170608" cellspacing="0">
            <tbody>
            <?php if($i==1){?>
            <tr>
                <td class="tableSubtitle odd"><?=lang('pk_bgh')?><span class="red">*</span></td>
                <td class="tableContent" colspan="3"><input class="form-control" type="text" value="<?=$orderFirst['maintain_id'].'_'.time()?>" readonly size="64px" name="package_id"></td>                                                            
            </tr>
             <tr>
                <td class="tableSubtitle even"><?=lang('pk_sjr')?><span class="red">*</span></td>
                <td class="tableContent" colspan="3"><input class="form-control" value="<?=$orderFirst['consumer_name']?>"  size="64px" id="consignee" name="consignee"></td>                                                            
            </tr>
            <tr>
                <td class="tableSubtitle odd"><?=lang('pk_hyfs')?><span class="red">*</span></td>
                <td class="tableContent">
                    <select class="form-control" name="delivery_method">
                        <option value="NaCex">NaCex</option>
                    </select>
                </td>
                <td class="tableSubtitle odd"><?=lang('pk_dh')?><span class="red">*</span></td>
                <td class="tableContent">
                    <input type="text" class="form-control" style="width:180px;" value="<?=$orderFirst['consumer_phone']?>"  size="64px" id="phone" name="phone">
                </td>
            </tr>
            <tr>
                <td class="tableSubtitle even"><?=lang('pk_jd')?><span class="red">*</span></td>
                <td class="tableContent"><input class="form-control" style="width:180px;" type="text" value="<?=$orderFirst['delivery_street_address']?>"  size="64px" id="RECEIPT" name="RECEIPT"></td>                                                            
                <td class="tableSubtitle even"><?=lang('pk_cs')?><span class="red">*</span></td>
                <td class="tableContent">
                    <input type="text" class="form-control" style="width:180px;" value="<?=$orderFirst['delivery_city']?>"  size="64px" id="city" name="city">
                </td>
            </tr>
            <tr>
                <td class="tableSubtitle odd"><?=lang('pk_gj')?><span class="red">*</span></td>
                <td class="tableContent">
                    <select class="form-control" style="width:180px;" id="country" name="country" style="width: 480px;">
                        <option value="ES"<?=$orderFirst['delivery_country']=='ES'?'selected':''?> >ES</option>
                        <option value="RU"<?=$orderFirst['delivery_country']=='RU'?'selected':''?> >RU</option>
                        <option value="DE"<?=$orderFirst['delivery_country']=='DE'?'selected':''?> >DE</option>
                        <option value="UK"<?=$orderFirst['delivery_country']=='UK'?'selected':''?> >UK</option>
                        <option value="US"<?=$orderFirst['delivery_country']=='US'?'selected':''?> >US</option>
                        <option value="PT"<?=$orderFirst['delivery_country']=='PT'?'selected':''?> >PT</option>
                        <option value="IT"<?=$orderFirst['delivery_country']=='IT'?'selected':''?> >IT</option>
                    </select>
                </td>                                                            
                <td class="tableSubtitle odd"><?=lang('pk_yb')?><span class="red">*</span></td>
                <td class="tableContent">
                    <input class="form-control" style="width:180px;" type="text" value="<?=$orderFirst['delivery_zipcode']?>"  size="64px" id="zipcode" name="zipcode">
                </td>
            </tr>
            <tr align="center">
                <td colspan="4" style="border:none;padding-top:20px;"><input class="btn btn-primary" type="submit" value="<?=lang('pk_scbg')?>" onclick="return AddPackage()"></td>
            </tr>
            <?php }else{?>
                <tr>
                    <td colspan="4" class="emptyNumber"><?=lang('pk_mykscbg')?></td>
                </tr>
            <?php }?>
            </tbody>
        </table>
    </form>
    
    <div id="shit" style="display: none">
    </div>
</div>
